/*
 * Copyright (c) 2010 Curtis Boyden.  All rights reserved. 
 * This software was developed by Curtis Boyden and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is ejMud
 * (Ewerp Java MUD).  The Initial Developer is Curtis Boyden.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/

package com.ewerp.mud.core;

import com.ewerp.mud.core.logging.ILog;
import com.ewerp.mud.core.plugin.IPlugin;

public class EwerpLog implements IPlugin, ILog {
    
    protected static EwerpLog instance = new EwerpLog();
    
    public static EwerpLog getInstance() {
        if(instance == null) {
            instance = new EwerpLog();
        }
        return instance;
    }
    
    protected EwerpLog() {
    }
    
    @Override
	public Class<?>[] getInterfaces() {
		return new Class<?>[] { ILog.class };
	}
    
    protected void println(String level, String message, Exception e) {
        System.out.println(level + ": " + message);
        if(e != null) {
            e.printStackTrace();
        }
    }

    @Override
    public void logDebug(String message) {
        println("Debug", message, null);
    }

    @Override
    public void logDebug(String message, Exception e) {
        println("Debug", message, e);
    }

    @Override
    public void logDetailed(String message) {
        println("Detailed", message, null);
    }

    @Override
    public void logDetailed(String message, Exception e) {
        println("Detailed", message, e);
    }

    @Override
    public void logError(String message) {
        println("Error", message, null);
    }

    @Override
    public void logError(String message, Exception e) {
        println("Error", message, e);
    }

    @Override
    public void logInfo(String message) {
        println("Info", message, null);
    }

    @Override
    public void logInfo(String message, Exception e) {
        println("Info", message, e);
    }

}
